home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / winprogs / ws_ping / ws_error.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-03  |  2.9 KB  |  82 lines

  1. /*************************************************************************
  2.  Windows Sockets Application ERROR Support Module
  3.  Written by John A. Junod, 267 Hillwood St., Martinez, GA, 30907 93.10.01
  4.  
  5.  Released into the public domain with no restrictions other than to give
  6.  me some of the credit if you use this code in other applications.  Some
  7.  code concepts based on code in Windows Sockets Finger Client, copyright
  8.  1992, Network Research Corporation.
  9. *****************************************************************************/
  10.  
  11. #include "ws_glob.h"
  12. #include "ws_ping.h"
  13.  
  14. struct WS_ERRORS
  15. {
  16.   UINT uErr;
  17.   LPSTR szText;
  18. };
  19.  
  20. #define NUMwsErrs 29
  21. struct WS_ERRORS wsErrs[] =
  22. {
  23.    WSAEINTR,         "INTR:Blocking call cancelled", // 4
  24.    WSAEFAULT,        "FAULT:from buf 2 small 4 peer addr", // 14
  25.    WSAEINVAL,        "INVAL:app ver not supported by DLL", // 22
  26.    WSAEMFILE,        "MFILE:no file desc avail", // 24
  27.    WSAEWOULDBLOCK,   "WOULDBLOCK:non-blocking and would block", // 35
  28.  
  29.    WSAEINPROGRESS,   "INPROGRESS:blocking operation in progress", // 36
  30.    WSAENOTSOCK,      "NOTSOCK:not a socket", // 38
  31.    WSAEPROTOTYPE,    "PROTOTYPE:wrong type for socket", // 41
  32.    WSAEPROTONOSUPPORT,"protocol not supported (try Trumpet Alpha 15)", // 43
  33.    WSAESOCKTNOSUPPORT,"socket type not supported for address family", // 44
  34.  
  35.    WSAEAFNOSUPPORT,  "address family not supported", // 47
  36.    WSAEADDRINUSE,    "address in use", //48
  37.    WSAENETDOWN,      "ENETDOWN:net subsystem failed (no arp response?)", // 50
  38.    WSAECONNABORTED,  "connection aborted",// 53
  39.    WSAECONNRESET,    "connection reset",// 54
  40.  
  41.    WSAENOBUFS,       "no buffer space available", // 55
  42.    WSAENOTCONN,      "not connected", //57
  43.    WSAETIMEDOUT,     "connection timed out", // 60
  44.    WSAECONNREFUSED,  "connection refused",  // 61
  45.    WSAEHOSTDOWN,     "host down", // 64
  46.  
  47.    WSAEHOSTUNREACH,  "host unreachable", // 65
  48.    WSASYSNOTREADY,   "WinSock not present or not responding", // 91
  49.    WSAVERNOTSUPPORTED,"Version of WinSock not supported", // 92
  50.    WSANOTINITIALISED,"WSA Startup not initialized", // 93
  51.    WSAHOST_NOT_FOUND,"Authoritive: Host not found", // 1001
  52.  
  53.    WSATRY_AGAIN,
  54.         "Non-authoritive: host not found or server failure", // 1002
  55.    WSANO_RECOVERY,   "Non-recoverable: refused or not implemented", // 1003
  56.    WSANO_DATA,       "Valid name, no data record for type", // 1004
  57.    WSANO_ADDRESS,    "Valid name, no MX record", // 1004
  58. };
  59.  
  60. LPSTR ReturnWSError(UINT nErr,LPSTR szBuf)
  61. {
  62.    int nIndex;
  63.    static char szErrMsg[128];
  64.  
  65.    if(szBuf==NULL) szBuf=szErrMsg;
  66.    for (nIndex = 0; nIndex < NUMwsErrs; nIndex++)
  67.    {
  68.       if (nErr == wsErrs[nIndex].uErr)
  69.       {
  70.          wsprintf((LPSTR)szBuf,(LPSTR)"%s",wsErrs[nIndex].szText);
  71.          return(szBuf);
  72.       }
  73.    }
  74.    wsprintf((LPSTR)szBuf, (LPSTR)"WS error %u", nErr);
  75.    return(szBuf);
  76. }
  77.  
  78. VOID ReportWSError(UINT nErr)
  79. {
  80.    DoAddLine(ReturnWSError(nErr,NULL));
  81. }
  82.